home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1802 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: news.uh.edu!usenet
  2. From: Sensarn <txs53132@bayou.uh.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Joystick
  5. Date: 13 Jan 1996 01:00:30 GMT
  6. Organization: AEtna Insurance Agency
  7. Message-ID: <4d707e$bc2@masala.cc.uh.edu>
  8. References: <4d48d3$23rm@holly.ACNS.ColoState.EDU>
  9. NNTP-Posting-Host: sip-14270.public-dialups.uh.edu
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1 (Windows; U; 16bit)
  14.  
  15. I/O port 201h:
  16.  
  17. bit definition
  18.  
  19. 0   Joystick 1 -- x axis
  20.  
  21. 1   Joystick 1 -- y axis
  22.  
  23. 2   Joystick 2 -- x axis
  24.  
  25. 3   Joystick 2 -- y axis
  26.  
  27. 4   Joystick 1 -- 1st button
  28.  
  29. 5   Joystick 1 -- 2nd button
  30.  
  31. 6   Joystick 2 -- 1st button
  32.  
  33. 7   Joystick 2 -- 2nd button
  34.  
  35. It all fits into one char!  If you want positions, use BIOS:
  36.  
  37. Interrupt 15h
  38.  
  39. subfunction in            out
  40.  
  41. 0           ah:84h dx:0   al:button state //Switch status
  42.  
  43. 1           ah:84h dx:1h  ax:joystick 1 -- x axis
  44.                           bx:joystick 1 -- y axis
  45.                           cx:joystick 2 -- x axis
  46.                           dx:joystick 2 -- y axis
  47.  
  48. bitmasks for button status
  49.  
  50. #define button_1_1 0x10
  51. #define button_1_2 0x20
  52. #define button_2_1 0x40
  53. #define button_2_2 0x80
  54.  
  55. If you are using an if(button...), you must invert the button status:
  56.  
  57. return((~outregs.h.al) & button); //Uses BIOS
  58.  
  59. Where button is any of the bitmasks.
  60.  
  61. Please notice that this information came from Teach Yourself Game 
  62. Programming in 21 Days.
  63.  
  64. Steven Sensarn - txs53132@bayou.uh.edu
  65.  
  66.  
  67.